<?php

/**
 * This is the model class for table "order_rating".
 *
 * The followings are the available columns in table 'order_rating':
 * @property string $id
 * @property string $order_id
 * @property string $user_id
 * @property string $worker_id
 * @property string $user_mobile
 * @property string $comment
 * @property double $rating_avg_quality
 * @property double $rating_avg_efficiency
 * @property double $rating_avg_satisfaction
 * @property double $rating_avg_manners
 * @property string $detail_str
 * @property string $create_time
 * @property string $update_time
 * @property string $created_by
 * @property string $updated_by
 * @property integer $is_delete
 * @property string $user
 */
class OrderRating extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return OrderRating the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'order_rating';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('is_delete', 'numerical', 'integerOnly'=>true),
			array('rating_avg_quality, rating_avg_efficiency, rating_avg_satisfaction, rating_avg_manners', 'numerical'),
			array('order_id, user_id, worker_id', 'length', 'max'=>64),
			array('user_mobile', 'length', 'max'=>256),
			array('created_by, updated_by', 'length', 'max'=>255),
			array('comment, detail_str, create_time, update_time, user', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, order_id, user_id, worker_id, user_mobile, comment, rating_avg_quality, rating_avg_efficiency, rating_avg_satisfaction, rating_avg_manners, detail_str, create_time, update_time, created_by, updated_by, is_delete, user', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'order_id' => 'Order',
			'user_id' => 'User',
			'worker_id' => 'Worker',
			'user_mobile' => 'User Mobile',
			'comment' => 'Comment',
			'rating_avg_quality' => 'Rating Avg Quality',
			'rating_avg_efficiency' => 'Rating Avg Efficiency',
			'rating_avg_satisfaction' => 'Rating Avg Satisfaction',
			'rating_avg_manners' => 'Rating Avg Manners',
			'detail_str' => 'Detail Str',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
			'created_by' => 'Created By',
			'updated_by' => 'Updated By',
			'is_delete' => 'Is Delete',
			'user' => 'User',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('order_id',$this->order_id,true);
		$criteria->compare('user_id',$this->user_id,true);
		$criteria->compare('worker_id',$this->worker_id,true);
		$criteria->compare('user_mobile',$this->user_mobile,true);
		$criteria->compare('comment',$this->comment,true);
		$criteria->compare('rating_avg_quality',$this->rating_avg_quality);
		$criteria->compare('rating_avg_efficiency',$this->rating_avg_efficiency);
		$criteria->compare('rating_avg_satisfaction',$this->rating_avg_satisfaction);
		$criteria->compare('rating_avg_manners',$this->rating_avg_manners);
		$criteria->compare('detail_str',$this->detail_str,true);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('created_by',$this->created_by,true);
		$criteria->compare('updated_by',$this->updated_by,true);
		$criteria->compare('is_delete',$this->is_delete);
		$criteria->compare('user',$this->user,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}